package com.weather.data.utils;

import cma.music.RetFilesInfo;
import cma.music.client.DataQueryClient;

import java.util.HashMap;

public class SkyKingUtil {


    public static RetFilesInfo requestSkyKing(String interfaceId, HashMap<String,String> params){
        /* 1. 定义client对象 */
        DataQueryClient client = new DataQueryClient();

        /* 2. 调用方法的参数定义，并赋值 */
        /* 2.1 用户名&密码 */
        String userId = "XA_QXDN";
        String pwd = "Xionganqixiang@2023";
        /* 2.4 返回对象 */
        RetFilesInfo retFilesInfo = new RetFilesInfo();

        /* 3. 调用接口 */
        try {
            //初始化接口服务连接资源
            client.initResources();
            //调用接口
            int rst = client.callAPI_to_fileList(userId, pwd, interfaceId, params, retFilesInfo);
            //输出结果
            if (rst == 0) { //正常返回
//                ClibUtil clibUtil = new ClibUtil();
//                clibUtil.outputRst(retFilesInfo);
                return retFilesInfo;
            } else { //异常返回
                System.out.println("[error] FileInfoSearchAPI_CLIB_callAPI_to_fileList.");
                System.out.printf("\treturn code: %d. \n", rst);
                System.out.printf("\terror message: %s.\n", retFilesInfo.request.errorMessage);
            }
        } catch (Exception e) {
            //异常输出
            e.printStackTrace();
        } finally {
            //释放接口服务连接资源
            client.destroyResources();
        }
        return null;
    }

}
